package hash;

import java.util.ArrayList;
import java.util.Arrays;


class Obj{
	public Integer mem = 12;

	
	public Integer getMem() {
		return mem;
	}

	public void setMem(Integer mem) {
		this.mem = mem;
	}
	
	Obj(Integer mem){
		this.mem = mem;
	}



	@Override
	public String toString() {
		return "Obj [mem=" + mem + "]";
	}

	@Override
	protected Object clone() throws CloneNotSupportedException {
		System.out.println("--------");
		Obj res = (Obj)super.clone();
		res.setMem(this.getMem());
		return res;
	}
	
	
	
}

public class CloneTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	
		
		Obj j1 = new Obj(1);
		Obj j2 = new Obj(2);
		Obj j3 = new Obj(3);
		Obj j4 = new Obj(4);
		
		
		Obj[] intarr = {j1,j2,j3,j4};
		Obj[] copIntarr = Arrays.copyOf(intarr, intarr.length);
		copIntarr[0].setMem(99);
		
		for(int j= 0;j<4; ++j){
			System.out.println(intarr[j] + "   "+ copIntarr[j]);
		}
		
		
	}

}
